<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>版位添加</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/switchery/switchery.min.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加版位</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" name="forma" id="forma" action="<?php echo U('position/save');?>" class="form-horizontal">
                    <input type="hidden" name="id" value="<?php echo ($posInfo["id"]); ?>" />
                    <!-- <input type="hidden" name="pid" value="<?php echo ($columnsInfo["pid"]); ?>" /> -->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">版位名称</label>

                            <div class="col-sm-10">
                                <input type="text" name="title" id="title" class="form-control" value="<?php echo ($posInfo["title"]); ?>">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">版位类型</label>
                            <div class="col-sm-10">
                                <select class="form-control m-b" name="type">
                                    <option value="">==请选择版位类型==</option>
                                    <option value="矩形横幅">矩形横幅</option>
                                    <option value="固定位置">固定位置</option>
                                    <option value="漂浮移动">漂浮移动</option>
                                    <option value="对联广告">对联广告</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">版位尺寸</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-2">
                                        <input type="text" name="width" id="width" placeholder="宽度 px" class="form-control" value="<?php echo ($posInfo["width"]); ?>">
                                    </div>
                                    <div class="col-md-2">
                                        <input type="text" name="height" id="height" placeholder="高度 px" class="form-control" value="<?php echo ($posInfo["height"]); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">广告数</label>

                            <div class="col-sm-10">
                                <input type="text" name="num" id="num" class="form-control" value="<?php echo ($posInfo["num"]); ?>">
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label">版位描述</label>

                            <div class="col-sm-10">
                                <input type="text" name="description" id="description" class="form-control" value="<?php echo ($posInfo["description"]); ?>">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>

                            <div class="col-sm-10">
                                <input type="checkbox" value="1" name="status" id="status" class="js-switch" <?php if($posInfo['status'] == 1): ?>checked<?php endif; ?> checked>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">添加</button>
                                <button class="btn btn-white" type="reset"  onclick="history.go(-1)">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.min.js"></script>
<script src="/Public/Admin/js/plugins/switchery/switchery.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/Public/Admin/js/common.js"></script>
<script>
    $(function(){
        $("#forma").validate({
            rules:{
                title:"required",
                type:"required",
            },
            messages:{
                title:'版位名不能为空!',
                type:'版位类型不能为空!',
            },
            submitHandler: function (form) {
                var objNames = $(form).serializeArray();
                var dataNames = new Object();
                $.each(objNames,function(key,val){
                    dataNames[val.name] = val.value;
                });
                $.ajax({
                        url:$(form).attr('action'),
                        type:'post',
                        dataType:'json',
                        data:dataNames,
                        success:function(data){
                           if(data.status > 0){
                               common.error(data.msg);
                           }else{
                               common.success(data.msg,"<?php echo U("position/index");?>");
                           }
                        }
                });
            }
        });
    });
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, { });
</script>
</html>